package 代码记录.指定公司代码练习记录.西安.分值100分未做;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author zx
 * @create 2023-07-09 16:03
 * 这个二分我看着很懵逼，没看懂！(自己肯定做不出来)
 */
public class 最佳植树距离种树 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();//坑位的数量
        int[] arr = new int[n];//坑位的位置
        for(int i = 0;i < arr.length;i++){
            arr[i] = sc.nextInt();
        }
        int k = sc.nextInt();//需要种植树苗的数量
        Arrays.sort(arr);
        int left = 0;
        int right = arr[arr.length - 1] - arr[0];
        int res = -1;
        while (left <= right) {
            int mid = left + (right - left) / 2;
            int count = 1;
            int previous = arr[0];

            for (int i = 1; i < arr.length; i++) {
                if (arr[i] - previous >= mid) {
                    count++;
                    previous = arr[i];

                    if (count >= k) {
                        res = mid;
                        left = mid + 1;
                        break;
                    }
                }
            }

            if (count < k) {
                right = mid - 1;
            }
        }
        System.out.println(res);
    }
}
